package com.lianniu.web.staff.service.impl;

import com.lianniu.web.base.BaseResult;
import com.lianniu.web.product.model.Page;
import com.lianniu.web.product.model.SkuProductVo;
import com.lianniu.web.staff.dao.StaffProductDao;
import com.lianniu.web.staff.service.StaffProductService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017-05-17.
 */

@Service
public class StaffProductServiceImpl implements StaffProductService {

    @Autowired
    StaffProductDao staffProductDao;
    @Override
    public BaseResult getList(String userId, int pageNum) {
        int count = this.staffProductDao.getListCount(userId);
        Page page = new Page(count, pageNum);
        List<SkuProductVo> list = this.staffProductDao.getList(userId, page);
        return BaseResult.success(list);
    }

    @Override
    public BaseResult offShelf(String id, String userId) {
        this.staffProductDao.offShelf(id, userId);
        return BaseResult.success();
    }

    @Override
    public BaseResult updateSku(@Param("id") String id, @Param("price") String price, @Param("stock") String stock, @Param("userId") String userId) {
        this.staffProductDao.updateSku(id, price, stock, userId);
        return BaseResult.success();
    }
}
